//
//  UIDevice+SXHDeviceFrame.m
//  ZLZKBaseUtils
//
//  Created by sxh on 2023/1/3.
//

#import "UIDevice+SXHDeviceFrame.h"

@implementation UIDevice (SXHDeviceFrame)

/// 设备安全区顶部高度
+ (CGFloat)dev_safeDistanceTop {
    if(@available(iOS 13.0, *)) {
        NSSet *set = [[UIApplication sharedApplication] connectedScenes];
        UIWindowScene *scene = [set anyObject];
        UIStatusBarManager *status = [scene statusBarManager];
        return status.statusBarFrame.size.height;
    } else if (@available(iOS 11.0, *)) {
        UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
        return  window.safeAreaInsets.top;
    }else {
        return 0;
    }

}
/// 设备安全部底部高度
+ (CGFloat)dev_safeDistanceBottom {
    if(@available(iOS 13.0, *)) {
        NSSet *set = [[UIApplication sharedApplication] connectedScenes];
        UIWindowScene *scene = [set anyObject];
        UIWindow *window = [scene windows].firstObject;
        return window.safeAreaInsets.bottom;
    } else if (@available(iOS 11.0, *)) {
        UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
        return window.safeAreaInsets.bottom;
    } else {
        return 0;
    }
}
/// 设备状态栏高度(包含安全区)
+ (CGFloat)dev_statusBarHeight {
    if(@available(iOS 13.0, *)) {
        NSSet *set = [[UIApplication sharedApplication] connectedScenes];
        UIWindowScene *scene = [set anyObject];
        UIStatusBarManager *status = [scene statusBarManager];
        return status.statusBarFrame.size.height;
    } else  {
        return  [UIApplication sharedApplication].statusBarFrame.size.height;
    }
}
/// 设备导航栏高度
+ (CGFloat)dev_navigationBarHeight {
    return 44.f;
}
/// 设备导航栏+状态栏高度
+ (CGFloat)dev_navigationFullHeight {
    return [UIDevice dev_statusBarHeight] + [UIDevice dev_navigationBarHeight];
}
/// 设备底部导航栏高度
+ (CGFloat)dev_tabBarHeight {
    return 49.f;
}
/// 设备底部导航栏高度(包含安全区)
+ (CGFloat)dev_tabBarFullHeight {
    return [UIDevice dev_tabBarHeight] + [UIDevice dev_safeDistanceBottom];
}


@end
